﻿using FluentValidation;
using System.ComponentModel.DataAnnotations;

namespace HSGD.Model.Validators;

public class UserRegisterVo {
    [Required]
    public string Name { get; set; }
    [Range(1,maximum:100)]
    [Required]
    public int? Quantity { get; set; }

    [Required]
    [StringLength(10)]
    public string? FullName { get; set; }

    [Required]
    public string? Phone { get; set; }
}


public class ProductValidator : AbstractValidator<UserRegisterVo> {
    public ProductValidator() {
        RuleFor(x => x.FullName)
            //.NotEmpty().WithMessage("The Full_Name field is required.")
            .MaximumLength(10).WithMessage("The Full_Name field must be between 1 and 10");

        RuleFor(x => x.Phone)
            //.NotEmpty().WithMessage("The Phone field is required.")
            .Length(0, 10).WithMessage("The Phone field Max Length 10");

        RuleFor(p => p.Name)
            //.NotEmpty().WithMessage("The Product Name field is required.")
            .MaximumLength(10).WithMessage("The Product Name field Max Length 10");

        RuleFor(p => p.Quantity)
            .GreaterThan(0).WithMessage("The Quantity field must be greater than 0");
    }
}
